package com.lagou.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;

import java.sql.SQLException;

/**
 * @Author ZHAO Yudong
 * @Date 2020/11/6 14:23
 * @description：
 */
public class DruidUtils {

	private static DruidDataSource druidDataSource = new DruidDataSource();

	static {
		druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
		druidDataSource.setDbType("com.alibaba.druid.pool.DruidDataSource");
		druidDataSource.setUrl("jdbc:mysql://10.36.0.120:3306/bank?characterEncoding=utf8&serverTimezone=UTC");
		druidDataSource.setUsername("root");
		druidDataSource.setPassword("soc");
	}


	private DruidUtils() {
	}

	public static DruidDataSource getInstance() {
		return druidDataSource;
	}

	public static void main(String[] args) {
		try {
			DruidPooledConnection connection = DruidUtils.getInstance().getConnection();
			System.out.println(connection);
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
	}

}
